###############################################################################
# Makefile
###############################################################################

ASM = avrasm2
TARGET = kk2_zmod.hex
MAIN_FILE = kk2.asm

TIMESTAMP := $(shell date '+0x20,0x%y,0x%m,0x%d')
FLAGS = -DBUILD_TIMESTAMP='$(TIMESTAMP)'

## Build
all: clean $(TARGET)

## Assemble
$(TARGET): $(MAIN_FILE)
	@echo
	@echo Generating hex file and EEPROM data
	@echo
	$(ASM) -fI -o $@ -e $(patsubst %.hex,%.eep,$(TARGET)) -m $(patsubst %.hex,%.map,$(TARGET)) $(FLAGS) $<

eeprom: $(MAIN_FILE)
	@echo
	@echo Generating EEPROM data
	@echo
	$(ASM) -fI -o temp.hex -e $(patsubst %.hex,%.eep,$(TARGET)) $(FLAGS) $<
	-rm -rf temp.hex

test:
	@echo $(TIMESTAMP)
	@echo $(FLAGS)

## Clean target
.PHONY: clean
clean:
	-rm -rf $(TARGET) $(patsubst %.hex,%.eep,$(TARGET))

